﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GameSchoolApplication.Models.ViewModels;
using GameSchoolApplication.Repositories;

namespace GameSchoolApplication.Controllers
{

    public class HomeController : Controller
    {

        /// <summary>
        /// Checks if the user has a login cookie in is browser, redirects to the front page if so. If not, back to the login page. 
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            if (Request.Cookies["userInfo"] == null)
            {
                return RedirectToAction("LogOn", "Account");
            }
            else
            {
                return RedirectToAction("CourseIndex","Course");
            }
            
        }
        
        /// <summary>
        /// Returns the user statistics page. 
        /// </summary>
        /// <returns></returns>
        public ActionResult stats()
        {
            string userID = Request.Cookies["userInfo"].Values["userID"];
            AccountRepository rep = new AccountRepository();
            return View("stats", rep.getPointsByUser(userID));
            
        }

        /// <summary>
        /// Returns the timetable page. 
        /// </summary>
        /// <returns></returns>
        public ActionResult timetable()
        {
            return View();
        }

        /// <summary>
        /// Returns the profile page. 
        /// </summary>
        /// <returns></returns>
        public ActionResult profile()
        {
            
            return View();
        }

        /// <summary>
        /// Returns the shop page. 
        /// </summary>
        /// <returns></returns>
        public ActionResult shop()
        {
            return View();
        }

        /// <summary>
        /// Returns the exams page. 
        /// </summary>
        /// <returns></returns>
        public ActionResult exams()
        {
            return View();
        }
        
        /// <summary>
        /// Returns the assignments page for the user. 
        /// </summary>
        /// <returns></returns>
        public ActionResult assignments()
        {
            string userID = Request.Cookies["userInfo"].Values["userID"];
            SubmissionRepository rep = new SubmissionRepository();
            return View("assignments", rep.getUserAssGrades(userID)); 
        }

        /// <summary>
        /// Returns the notifications page. 
        /// </summary>
        /// <returns></returns>
        public ActionResult notifications()
        {
            return View();
        }

        /// <summary>
        /// Returns the management page. 
        /// </summary>
        /// <returns></returns>
        public ActionResult manage()
        {
            return View();
        }

        /// <summary>
        /// Returns the notifications page. 
        /// </summary>
        /// <returns></returns>
        public ActionResult notification()
        {
            return View();
        }

        
    }
}
